package com.jason.data.entity;

import lombok.Data;
import lombok.ToString;
import lombok.experimental.Accessors;
import org.springframework.data.mongodb.core.index.CompoundIndex;
import org.springframework.data.mongodb.core.index.Indexed;
import org.springframework.data.mongodb.core.mapping.Document;

import java.util.Date;

@Data
@Document(value = "users") //创建集合名称
@ToString
@CompoundIndex(def="{'age':1,'phone':-1}")  //创建复合索引
@Accessors(chain = true)
public class User {

//    @MongoId(FieldType.OBJECT_ID)
//    @Field("_id")
//    private Object id;

    @Indexed(name = "index_name")
    private String name;

    private int age;

    private String phone;

    private String addr;

    private Date birth;
}
